package demo;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jfinal.handler.Handler;

public class PermissionHandler extends Handler {

	@Override
	public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
		
//		Const.LOGINUSER
		int indexJsp = target.lastIndexOf(".jsp");
		int indexHtml = target.lastIndexOf(".html");
		if ("/".equals(target) || indexJsp != -1 || indexHtml != -1) {
			
			try {
				request.getRequestDispatcher(target).forward(request, response);
			} catch (ServletException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		nextHandler.handle(target, request, response, isHandled);
	}
}